package com.bw.flow

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf

class TestViewModel:ViewModel() {

    //冷流
    val flow1 =  flow {
        var time = 0
        while (true) {
            emit(time)
            delay(1000)
            println("flow1: 发射数据")
            time++
        }
    }
}